package edu.fim.core.service.locator;

import java.util.ServiceLoader;


public class ServiceLocator {

	public static <T> T getImplementation(Class<T> clazz) {
		ServiceLoader<T> implementations = ServiceLoader.load(clazz);
		for (T aClazz : implementations) {
			if (aClazz != null) {
				return aClazz;
			}
		}
		throw new RuntimeException("Cannot find implementation for " + clazz.getName());
	}
}